package com.manage.result;

/**
 * @author 王焕龙
 * @date 2020/2/11 9:57
 * @Description: 网络请求基本返回
 */

public class Result<T> {

    private int code;

    private String msg;

    private  T data;

    public  static <T>Result<T> success(T data){
        return  new Result<T>(data);
    }

    public static  <T>Result<T>error(CodeMsg codeMsg){

        return  new Result<T>(codeMsg);
    }


    private Result(T data){
        this.code=0;
        this.msg="Success";
        this.data=data;
    }

    private Result(CodeMsg codeMsg){
        if(codeMsg==null)
            return;

        this.code=codeMsg.getCode();
        this.msg=codeMsg.getMsg();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public T getData() {
        return data;
    }

}
